package com.springmvc.web.servlet.mvc.method.annotation;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import com.springmvc.ui.ModelMap;
import com.springmvc.web.servlet.HandlerAdapter;
import com.springmvc.web.servlet.ModelAndView;


/**
 * 为了 @RequestMapping 准备的处理器适配器
 */
public class RequestMappingHandlerAdapter implements HandlerAdapter {
    @Override
    public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        ModelAndView mv = new ModelAndView();
        mv.setViewName("index");
        ModelMap modelMap = new ModelMap();
        modelMap.addAttribute("name", "张三");
        mv.setModel(modelMap);
        return mv;
    }
}
